<?php
namespace app\index\controller;
use think\facade\View;
use think\facade\Db;
use think\facade\Request;
class Page extends Base{
    public function __construct(\think\App $app) {
        parent::__construct($app);
        $this->page_id=Request::param("page_id",0,"intval");
        $this->page=Db::name("page")->find($this->page_id);
        if(!$this->page){
            $this->error("页面不存在！");
        }
        View::assign($this->page);
        //tdk字段
        View::assign("pagetitle",$this->page['pagetitle']?$this->page['pagetitle']:$this->page['title']);//pagetitle
        View::assign("keywords",$this->page['pagekey']);//关键词
        View::assign("description",$this->page['pagedes']);//描述

    }    
    public function index(){
        //直接页面试只需要输出模板即可
        if($this->page["pagemod"]==1){
            return View::fetch(base_path().'data/templateFile/page_'.$this->page_id.".html");
        }else{
            //内容式需要输出自定义模板页面
            return View::fetch(base_path().'data/templateFile/'.$this->page['template_id'].".html");      
        }
    }             
}